<template>
  <div class="my_nav" :class="{ is_home: isHome }">
    <div class="my_nav_con">
      <div class="goback icon" @click="goback" v-if="gobackShow">
        <van-icon name="arrow-left" />
      </div>
      <div class="nav_title">
        <span class="title_box">{{ title }}</span>
        <span class="clear" @click="onClear" v-if="clear">
          <i class="iconfont icon-qingchushujuku"></i>
        </span>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'MyNavBar',
  components: {},
  props: {
    title: {
      type: String,
      default: '互联网+公务员平时考核',
    },
    gobackShow: {
      type: Boolean,
      default: true,
    },
    clear: {
      type: Boolean,
      default: false,
    },
  },
  data() {
    return {}
  },
  computed: {
    isHome() {
      return this.$route.name === 'Home'
    },
  },
  watch: {},
  created() {},
  mounted() {},
  methods: {
    goback() {
      this.$emit('goback')
    },
    onClear() {
      this.$emit('clear')
    },
  },
}
</script>

<style lang="scss" scoped>
.my_nav {
  display: flex;
  align-items: center;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 46px;
  z-index: 999;
  background-color: #ffffff;
  border-bottom: 1px solid #eee;
  .my_nav_con {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
    font-size: 16px;
    padding: 0 20px;
    overflow: hidden;
    div {
      height: 100%;
      display: flex;
      justify-content: center;
      align-items: center;
      font-size: 16px;
      color: #333333;
    }
    .icon {
      padding-right: 20px;
      position: absolute;
    }
    .nav_title {
      flex: 1;
      text-align: center;
      font-size: 18px;
      overflow: hidden;
      .title_box {
        width: 85%;
        @include ellipsis;
      }
      .clear {
        position: absolute;
        right: 16px;
        font-weight: 400;
        .iconfont {
          font-size: 16px;
        }
      }
    }
  }
}
.is_home {
  background-color: transparent;
  background-image: url('../assets/images/home/nav.png');
  background-size: cover;
  border-bottom: 0;
  .title_box {
    color: #ffffff;
  }
}
</style>
